package com.ljh.controller;

import com.ljh.mapper.CityMapper;
import com.ljh.pojo.City;
import com.ljh.service.ICityService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/city")
public class CityController {

    @Autowired
    private ICityService cityService;

    @GetMapping
    public List<City> listAll(){
        return cityService.list();
    }

    @GetMapping("/{id}")
    public City city(@PathVariable("id") int id){
        return cityService.getById(id);
    }

    @DeleteMapping("/{id}")
    public String deletecity(@PathVariable("id") int id){
        cityService.removeById(id);
        return "删除成功";
    }
}
